package Logging;

import java.util.ArrayList;
import java.util.Hashtable;

public class Server implements Runnable{
	
	private LoggingService loggingService;
	@Override
	public void run() {
		
		while(true)
		{
			Hashtable<Message.MessageImportance, ArrayList<Message>> messageBuffer= loggingService.getMessageBuffer();
			for (Message.MessageImportance mi : Message.MessageImportance.values())
			{
				for(int i=0;i<messageBuffer.get(mi).size();i++)
				{
					Message message=messageBuffer.get(mi).get(i);
					
					System.out.println("["+message.getMessageImportance()+"]("+message.getMessageImportance().getPriority()+") "+message.getText());
					messageBuffer.get(mi).remove(messageBuffer.get(mi).get(i));
				}
			}
			
		}
		
	}
	
	public Server(LoggingService loggingService)
	{
		this.loggingService=loggingService;
		
	}

}
